package com.dc.system.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dc.common.aop.AuthorityAop;
import com.dc.common.aop.LogAop;
import com.dc.common.constants.ConstantsCommon;
import com.dc.common.em.EnumOperationModule;
import com.dc.common.model.BaseModel;
import com.dc.system.model.SysLoginLog;
import com.dc.system.model.SysUser;
import com.dc.system.service.UserService;
import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
import com.wordnik.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/user")
public class UserController {

	@Autowired
	private UserService userService;

	@ApiOperation(value = "用户登陆", httpMethod = "GET")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "account", value = "登陆用户名", required = true, paramType = "query"),
			@ApiImplicitParam(name = "password", value = "登录用户密码", required = true, paramType = "query") })
	@RequestMapping("/login")
	@ResponseBody
	public BaseModel login(BaseModel baseModel, SysLoginLog sysUserLoginLog, SysUser sysUser, HttpServletRequest request) throws Exception {
		return userService.login(baseModel,sysUserLoginLog, sysUser,request);
	}
	
	@AuthorityAop(module = EnumOperationModule.No101, type = ConstantsCommon.FUN_SEARCH)
	@LogAop(module = EnumOperationModule.No101, type = ConstantsCommon.FUN_SEARCH)
	@RequestMapping("/test")
	@ResponseBody
	public BaseModel test(BaseModel baseModel, HttpServletRequest request) throws Exception{
		return userService.getUserPermission(baseModel,request);
	}
}
